package ControlLayer;
import java.util.ArrayList;
import ModelLayer.*;
//model layer package has to be imported
 
/**
 * Controller class for the address book
 * 
 * @author (kbh) 
 * @version (2005.03.31)
 * (FEN): 2006.03.21: Some changes to the architecture in order to assure layering
 *                    and loose coupling
 */
public class AddressCtr
{
    private AddressBook addressBook; 
    
    /**
     * Constructor
     */
    public AddressCtr()
    {
        addressBook = new AddressBook();
    }
    
    /**
     * Returns the person object with the given ID.
     * Returns null if the person does not exist
     */
    public Person getPerson(int id)
    {
        Person person = addressBook.getPerson(id);
        return person;
    }
    
    /**
     * Removes a person from the address book
     * 
     * @param   id  the ID of the person to be removed
     */
    public void removePerson(int id)
    {
        //the search is done in the container (to avoid coupling between this class and the Person-class)
        addressBook.removePerson(id);
    }
    
    /**
     * Returns the address book
     */
    public ArrayList<Person> listAllPersons()
    {
          return addressBook.getAllPersons();
    }
    
     /**
      * creates a Person object and stores it in the address book
      */
    public void addPerson(int id, String name, String address, String zipCode, String city, String phoneNumber)
    {
        addressBook.addPerson(id, name, address, zipCode, city, phoneNumber);
    }
    
    
}
